package DAO.impl.jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

import org.apache.log4j.Logger;

public abstract class JdbcDAO {

	private static Logger log = Logger.getLogger(JdbcDAO.class);

	private String dbusername = "postgres";
	private String dbpassword = "password";
	private String dburl = "jdbc:postgresql://localhost:5432/DinamyteChatDB";

	static {
		try {
			Class.forName("org.postgresql.Driver");
		} catch (ClassNotFoundException e) {
			throw new ExceptionInInitializerError(e);
		}
	}

	public Connection GetConnection() {

		Connection con = null;

		try {
			con = DriverManager.getConnection(dburl, dbusername, dbpassword);
		} catch (SQLException e) {
			log.error(e.getMessage());			
		}

		return con;

	}

}
